{% extends "base.html" %}
{% load utils %}

{% block content %}
<div id="content-header">
<h2>账户列表</h2>
<div class="top-tools">
	<a href="/sa/new/" class="create_account">创建新帐户</a>
</div>
<div class="clear"></div>
</div>
{% if accounts %}
<ul>
{% for account in accounts %}
<li class="object-item {% cycle '' 'alt' %}">
	<div class="main">
		<a href="/sa/{{ account.key.id }}/" class="sa">{{ account.name }}</a>
		<p class="tools">
			<a class="edit" href="/sa/{{ account.key.id }}/edit/">编辑</a>
			<a class="delete delete_account" href="/sa/{{ account.key.id }}/delete/">删除</a>
		</p>
	</div>
	<p class="detail">账户总余额{{ account.amount }}元，我的余额{{ account|member_amount:request.user }}元，{{ account.creator.name }}创建于{{ account.created|format_time }}</p>
</li>
{% endfor %}
</ul>
{% else %}
<div class="blankslate">
	<p>您还没有任何共享帐户，赶快<a href="/sa/new/" class="create_account big">创建</a>一个吧</p>
</div>
{% endif %}

<div class="bottom-tools">
	<a class="button" href="/sa/new/">创建新账户</a>
</div>
{% endblock %}

{% block embedded_javascript %}
(function($) {
	$(function() {
		$("a.delete_account").click(function() {
			if (confirm("确定要删除该帐户及其相关的所有交易吗?")) {
				return true;
			}
			return false;
		});
		$(".object-item").hover(
			function() {
				$(this).find(".tools").show();
			},
			function() {
				$(this).find(".tools").hide();
			}
		);
	});
})(jQuery);
{% endblock %}
